var jwt = require('jsonwebtoken')

let secret = 'yikeshi'


exports.genToken = function (id) {
    let payload = { id: id, time: new Date() }
    let token = jwt.sign(payload, secret, { expiresIn: 60 * 60 * 24 * 120 })
    return token;
}


exports.verifyToken = function (e) {
    let payload = jwt.verify(e, secret)
    return payload;
}